package com.aaa.controller;

import com.aaa.dao.UserDaos;
import com.aaa.dao.UserMapper;
import com.aaa.entity.User;
import com.aaa.service.UserService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.sql.Date;
import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {
    @Resource
    UserService userService;
    @Resource
    UserMapper userMapper;
    @Resource
    UserDaos userDaos;
    @RequestMapping("login")
    public List<User> select(String name, String password){
//        List<User> rs=userService.select();
//        System.out.println(rs);
//        model.addAttribute("list1",rs);
        return userService.login(name,password);
    }


    @RequestMapping("select")

    public Object select(Integer pageCode, Integer pageSize, User user){
        System.out.println(user);
        return userService.select(pageCode, pageSize, user);
    }
    @RequestMapping("insert")

    public Integer insert(com.wsc.entity.User f_user){
        return userMapper.insert(f_user);
    }

    @RequestMapping("updateP")
    public Integer updateP(String password,Integer uid) {
        System.out.println(password);
        User user=new User();
        user.setPassword(password);
        user.setUid(uid);
        return userService.updateP(user);
    }

    @RequestMapping("update")
    public Integer update(com.wsc.entity.User user) {

        return userMapper.updateById(user);
    }
    @RequestMapping("updateS")

    public Integer updateS(User f_user) {
        return userService.updateS(f_user);
    }

    @RequestMapping("select3")
    public Object select3(){
        return userMapper.selectList(null);
    }

    @RequestMapping("selectSelf")
    public Object selectSelf(Integer uid){
        System.out.println(uid+"=======================================");
        User user=new User();
        user.setUid(uid);
        return userDaos.selectSelf(user);
    }
    @RequestMapping("select8")
    public Object select8(){
        return userDaos.select8();
    }

}
